package com.wenlong.train_ticketing_system_springboot.querymodule.config;

//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//
///**
// * @author 苏文龙
// * @version 1.0
// */
//@Configuration
//public class SpringSecurityConfig1 extends WebSecurityConfigurerAdapter {
//    @Autowired
//    private UserDetailsService userDetailsService;
//
//    @Override
//    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//        // 创建配置类,设置使用哪个 userDetailsService 实现类
//        auth.userDetailsService(userDetailsService).passwordEncoder(password());
//    }
//
//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
//        http.formLogin()
//                .loginPage("/login.html") // 自定义登录页面
//                .loginProcessingUrl("/user/login") // 自定义登录访问路径, 这是他自己的 controller, 不需要我们写
//                .defaultSuccessUrl("/trainT/index").permitAll() // 成功跳转路径, 注意是 `Get` 提交
//                .and().authorizeRequests()
//                .antMatchers("/", "/user/login").permitAll() // 直接放行免访问路径
//                .anyRequest().authenticated()
//                .and().csrf().disable(); // 禁用 csrf 防护
//    }
//
//    @Bean
//    public PasswordEncoder password(){
//        return new BCryptPasswordEncoder();
//    }
//}
